﻿using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace MvcFlow.Tests
{
    public static class SerializationHelper
    {
        public static T Roundtrip<T>( T value )
        {
            using( var stream = new MemoryStream())
            {
                new BinaryFormatter().Serialize(stream,value);
                stream.Seek(0L, SeekOrigin.Begin);

                return (T)new BinaryFormatter().Deserialize(stream);
            }
        }
    }
}